<?php
include __DIR__.'/../vendor/autoload.php';
use \xlx\Actor;

$server = new \xlx\DispatchServer([
    'ip_addr'=> '127.0.0.1',
    'ip_port'=> 8109, 
    'proc_min'=>0,
    'proc_max'=>4,
    'profile'=>__DIR__.'/nil',
]);

$worker1 = new \Workerman\Worker();
$worker1->count = 4;
$worker1->onWorkerStart=function($conn){
    Actor::connect('127.0.0.1',8109);
    sleep( rand(0,6) );
    \Workerman\Lib\Timer::add(0.01,function()use($conn){ 
        Actor::create(function(Actor $actor)use($conn){
            yield $actor->register('name');
            yield $actor->receive(function($data)use($conn){
                $data['conn'] = $conn->id; 
                print_r($data);
            },0.01);
            //echo 'exit';
        }); 
    },[],true);
};

 

\Workerman\Worker::runAll();
 